<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../org/angular.min.js"></script>
</head>
<body>
    <div ng-app="vm" ng-controller="ctrl">
         <table border="1px solid #ccc" width="600">
             <tr>
                 <td ng-click="orderBy('id')">编号</td>
                 <td ng-click="orderBy('click')">点击数</td>
                 <td ng-click="orderBy('title')">标题</td>
             </tr>
             <tr ng-repeat="(k,v) in data">
                 <td>{{v.id}}</td>
                 <td>{{v.click}}</td>
                 <td>{{v.title}}</td>
             </tr>
         </table>
    </div>
    <script>
        var vm = angular.module('vm',[]);
        vm.controller('ctrl',['$scope','$filter',function($scope,$filter){
            $scope.data = [
                {id: 1,click: 100,title: '后盾人'},
                {id: 2,click: 200,title: 'PHP'},
                {id: 3,click: 300,title: '后盾网'}
            ]
            $scope.orderBy = function(filed){
                //   if(arguments.callee[filed]==undefined){
                //       arguments.callee[filed] = false;
                //   }
               arguments.callee[filed] = !arguments.callee[filed];
               $scope.data = $filter("orderBy")($scope.data,filed,arguments.callee[filed])
            }
        }])
    </script>
</body>
</html>